"""
  这份文件用来绘图
"""

# 导入外部包
import matplotlib.pyplot as plt
import numpy as np

import math

plt.rcParams["font.sans-serif"] = ["SimHei"]
plt.rcParams["axes.unicode_minus"] = False
plt.rc("font", size=15)

# 绘制折线图（datas为数组，数组内部为字典类型，字典中包含data属性和des属性）
def draw_line_chart(data_x, datas_y, labels, title="默认标题", y_ticks=None):
  for i in range(len(datas_y)):
    # 填充数据
    plt.plot(data_x, datas_y[i]["data"], marker="o", markersize=1, label=datas_y[i]["des"])

  # 处理刻度线
  if y_ticks != None:
    # # 寻找中心点
    # res_min = 10000000
    # res_max = -10000000
    # for i in range(len(datas_y)):
    #   cur_max = max(datas_y[i]["data"])
    #   cur_min = min(datas_y[i]["data"])
    #   if (cur_max - cur_min > res_max - res_min):
    #     res_max = cur_max
    #     res_min = cur_min

    # # 计算范围范围
    # y_ticks = np.arange(res_min, res_max, ticks)

    # # 设置y轴刻度范围
    # plt.ylim(res_min, res_max)
    plt.yticks(y_ticks)

  plt.xlabel(labels["x"])
  plt.ylabel(labels["y"])
  plt.title(title)
  plt.legend()
  plt.show()